package com.itheima.service;

import com.itheima.bean.Admin;
import com.itheima.bean.Course;
import com.itheima.bean.Student;
import com.itheima.dao.SutdentDao;

import java.io.IOException;
import java.util.ArrayList;

public class StudentService {
    SutdentDao sutdentDao = new SutdentDao();
    public boolean istrue(String uid, String upassword) throws IOException {
        ArrayList<Student> readstudent = sutdentDao.readstudent();
        boolean flag = false;
        for (Student student : readstudent) {
            if (uid.equals(student.getSid()) || upassword.equals(student.getPassword())) {
                return flag = true;
            }
        }
        return flag;
    }

    public boolean isExits(String id) throws IOException {
        ArrayList<Course> id1 = sutdentDao.findId();
        boolean flag = false;
        for (Course course : id1) {
            if (id.equals(course.getCid())) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    public boolean addcourse(Course course) throws IOException {
        return sutdentDao.addcourse(course);
    }

    public void deletecourse(String id) throws IOException {
        sutdentDao.deletecourse(id);
    }

    public void findcourse() throws IOException {
        sutdentDao.findcourse();
    }
}
